*********************************************************
**     Actuals.do********************************** 
*This replicates Ashenfelter/Hosken, and applies their method*
*to rival brands.*************************************
*********************************************************
*clusters are region/half years*
clear
clear mata
clear matrix
set mem 400m
set more off
*use "K:\BE\Consumer_Product\weinberg_hosken_paper\restat_stuff\pass_thru\syrup2_22"
use "h:\data\restat_12_9\analysis_data\syrup2_22"

/*cd \Data\Hoskenpaper*/
cap log close
log using "h:\data\restat_12_9\logfiles\pancake_corn_syrup.log", replace
keep if type=="MAPLE/PANCAKE & WAFFLE SYRUP"

*drop if REGION=="ALBANY"|REGION=="BOISE"|REGION=="BOSTON"|REGION=="HARTFORD/SPRINGFLD"|REGION=="NEW ENGLAND(NORTH)"|REGION=="NEW YORK"|REGION=="PROVIDENCE"|REGION=="SALT LAKE CITY"|REGION=="SPOKANE"|REGION=="TULSA"|REGION=="WICHITA"|REGION=="LOS ANGELES"|REGION=="SACRAMENTO"|REGION=="SAN DIEGO"|REGION=="SAN FRAN/OAKLAND"|REGION=="PORTLAND"|REGION=="SEATTLE/TACOMA";
/*These are the largest 9 brands and they make up 86 percent of total revenue for our entire sample*/
keep if BRAND=="AUNT JEMIMA"|BRAND=="HUNGRY JACK"|BRAND=="LOG CABIN"|BRAND=="MRS BUTTERWORTH"|BRAND=="PRIVATE LABEL"/*
*/|BRAND=="AUNT JEMIMA LIGHT"|BRAND=="JACK LITE"|BRAND=="LOG CABIN LIGHT"|BRAND=="MRS BUTTERWORTH LITE"|BRAND=="GENERIC"

drop week DAY type
collapse (sum) AVOL ASALE, by(BRAND REGION YEAR MONTH)
sort REGION BRAND YEAR MONTH
gen tyear=YEAR*100
gen t=tyear+MONTH
sort YEAR MONTH
merge YEAR MONTH using "h:\data\restat_12_9\raw\corn_syrup_spot.dta"
tab _merge
drop _merge
/*create cluster*/

gen half_year=0
replace half_year=1 if MONTH>6

gen time1=YEAR*10+half_year
encode REGION,gen(region)
gen region_halfyear=time1*100+region
tab region_halfyear




gen merged=t>=199707
/*Pre-trends here*/
gen month1=MONTH/2
replace month1=int(month1)
gen T=YEAR*100+month1
tab T,gen(T)
gen date=ym(YEAR,MONTH)
format date %tm
gen lc=0
gen lc_light=0
gen mb=0
gen mb_light=0
gen pl=0
label var lc "Log Cabin"
label var lc_light "Log Cabin Light"
label var mb "Mrs Butterworth"
label var mb_light "Mrs Butterworth Light"
label var pl "Private Label"
replace AVOL=AVOL*24/16

gen aprice=ASALE/AVOL
gen lprice=log(aprice)
gen lcorn=log(price_corn_syrup)
qui xi: reg lprice  T1-T30 i.REGION if (BRAND=="LOG CABIN"), nocons
forval x=1/30{
	replace lc=_b[T`x'] if T`x'==1
}

qui xi: reg lprice  T1-T30  i.REGION if (BRAND=="LOG CABIN LIGHT"), nocons
forval x=1/30{
	replace lc_light=_b[T`x'] if T`x'==1
}

qui xi: reg lprice  T1-T30  i.REGION if (BRAND=="MRS BUTTERWORTH"), nocons
forval x=1/30{
	replace mb=_b[T`x'] if T`x'==1
}

qui xi: reg lprice  T1-T30  i.REGION if (BRAND=="MRS BUTTERWORTH LITE"), nocons
forval x=1/30{
	replace mb_light=_b[T`x'] if T`x'==1
}

qui xi: reg lprice  T1-T30  i.REGION if (BRAND=="PRIVATE LABEL"), nocons
forval x=1/30{
	replace pl=_b[T`x'] if T`x'==1
}

sort date
twoway (line lc date if BRAND=="LOG CABIN"&t<199805, clcolor(gs0) lpattern(..-..-))||(line lc_light date if BRAND=="LOG CABIN LIGHT"&t<199805, clcolor (gs10) lpattern(..-..-))/*
*/||(line mb date if BRAND=="MRS BUTTERWORTH"&t<199805, clcolor(gs0) lpattern(----))||(line mb_light date if BRAND=="MRS BUTTERWORTH LITE"&t<199805, clcolor (gs10) lpattern(----))||(line pl date if BRAND=="PRIVATE LABEL"&t<199805, clcolor(gs0)), /*
*/ytitle("log price($/Pint)") xline(450) text(.40 450 "Merger Consummated", orientation(vertical) placement(e)) graphregion(color(white)) bgcolor(white)

graph export "c:\data\restat\figures\SyrupPlot.eps", replace
	
	/*Parallel pre-merger trend test*/
gen branded=1
replace branded=0 if BRAND=="PRIVATE LABEL"|BRAND=="GENERIC"
gen t_b=t*(branded)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="LOG CABIN"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="LOG CABIN LIGHT"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="MRS BUTTERWORTH"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="MRS BUTTERWORTH LITE"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="AUNT JEMIMA"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="AUNT JEMIMA LIGHT"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="HUNGRY JACK"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)
xi: reg lprice t t_b i.REGION*i.branded if (merged==0)&(BRAND=="JACK LITE"|BRAND=="PRIVATE LABEL"), cluster(region_halfyear)





drop if t>199703&t<199711|t>199804|t==199610

gen dd=branded*merged
gen b_lcorn=branded*lcorn


xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="AUNT JEMIMA"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear)
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="AUNT JEMIMA LIGHT"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear)
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="HUNGRY JACK"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear)
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="JACK LITE"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear)
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="LOG CABIN"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear) 
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="LOG CABIN LIGHT"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear) 
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="MRS BUTTERWORTH"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear) 
xi: reg lprice lcorn b_lcorn i.MONTH i.REGION*i.branded merged dd if BRAND=="MRS BUTTERWORTH LITE"|BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear)




xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="AUNT JEMIMA", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="AUNT JEMIMA LIGHT", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="HUNGRY JACK", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="JACK LITE", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="LOG CABIN", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="LOG CABIN LIGHT", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="MRS BUTTERWORTH", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="MRS BUTTERWORTH LITE", cluster(region_halfyear) 
xi: reg lprice lcorn i.MONTH i.REGION merged  if BRAND=="PRIVATE LABEL"|BRAND=="GENERIC", cluster(region_halfyear) 


log close



